
<!--------------------------------------------黄笠煌------------------------------------------------------------------>
<template>
    <div><!--：model绑定表单对象，相当于给该表单取名为ruleForm-->
        <h1>京东订单多维调度系统登陆界面</h1>

    <el-form :model="ruleForm" :rules="rules" ref="ruleForm" label-width="100px" class="demo-ruleForm">
        <el-form-item label="账号" prop="userid"><!--prop绑定校验规则-->
            <el-input v-model="ruleForm.userid"></el-input><!--v-model绑定输入与表单对象ruleForm属性值-->
        </el-form-item>
        <el-form-item label="密码" prop="password"><!--prop绑定校验规则-->
            <el-input v-model="ruleForm.password"></el-input>
        </el-form-item>

        <el-form-item>
            <el-button type="primary" @click="submitForm('ruleForm')">登陆</el-button>
            <el-button @click="resetForm('ruleForm')">重置</el-button>
            <el-button type="primary" @click="submitForm('ruleForm')">注册</el-button>
        </el-form-item>
    </el-form>
    </div>
</template>

<script>
    export default {
        data() {
            return {
                ruleForm: {
                    userid: '',
                    password:''
                },
                rules: {
                    userid: [
                        { required: true, message: '请输入账号', trigger: 'blur' },
                        {  max: 20, message: '长度在 20个字符内', trigger: 'blur' }
                    ],
                    password: [
                        { required: true, message: '请输入密码', trigger: 'blur' },
                        {  max: 20, message: '长度在 20个字符内', trigger: 'blur' }
                    ],
                }
            };
        },
        methods: {
            submitForm(formName) {
                this.$refs[formName].validate((valid) => {
                    if (valid) {
                        //在此向后端发送请求处理并获取返回值判断登陆是否成功
                        alert('登陆成功！');
                        this.$router.push('/Displayrule')//已可跳转到条件查询页面

                    } else {
                        console.log('error submit!!');
                        return false;
                    }
                });
            },
            resetForm(formName) {
                this.$refs[formName].resetFields();
            }
        }
    }
</script>